<!DOCTYPE html>
<html>
<head>
    <script src="js/jquery-3.3.1.js"></script>
    <meta charset="UTF-8">
    <title>修改密码</title>
    <style>
        html,
        body {
            height: 100%;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .container {
            width: 300px;
            padding: 20px;
            border: 1px solid #ccc;
            border-radius: 5px;
            background-color: #f9f9f9;
        }

        h1 {
            text-align: center;
        }

        form {
            display: flex;
            flex-direction: column;
        }

        label {
            margin-bottom: 10px;
        }

        input {
            padding: 5px;
        }

        button {
            padding: 10px;
        }
    </style>
    <script>
        $(function(){
            $("#changePassword").submit(function(){
                var oldPassword = document.getElementById("oldPassword").value;
                var newPassword = document.getElementById("newPassword").value;
                var confirmPassword = document.getElementById("confirmPassword").value;

                if (newPassword !== confirmPassword) {
                    alert("确认密码与新密码不一致！");
                    return false;
                }
                $.post("user/updatePassword", {
                    oldPassword: oldPassword,
                    newPassword: newPassword
                }, function (data) {
                    alert(data.errorMsg);
                });
            });
        });
    </script>
</head>
<body>
<div class="container">
    <h1>修改密码</h1>
    <form id="changePassword" action="user/updatePassword">
        <label for="oldPassword">旧密码:</label>
        <input type="password" id="oldPassword" name="oldPassword" required>
        <label for="newPassword">新密码:</label>
        <input type="password" id="newPassword" name="newPassword" required>
        <label for="confirmPassword">确认密码:</label>
        <input type="password" id="confirmPassword" name="confirmPassword" required>
        <button type="submit">提交</button>
    </form>
</div>

</body>
</html>